package ioc;

import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

//@Component意思是组件
//这个注解一旦标记,表示当前类要自动实例化对象,并保存到Spring容器中
//这个对象保存到Spring容器中的id就是当前类名,只是首字母要小写
@Component
//@Scope("prototype")
@Lazy
public class Hero {

    private String name="关羽";
    private String job="战士";

    public Hero(){
        System.out.println("Hero实例化...");
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", job='" + job + '\'' +
                '}';
    }
}
